IF (NOT VISUALIZER)
	SET(VISUALIZER 0 CACHE BOOL "Enable the visualizer module, based on the SFML C++ library.")
ENDIF()

IF (VISUALIZER)
	# Visualizer support via the SFML C++ library
	PKG_CHECK_MODULES(SFML REQUIRED sfml-graphics>=2.3.0)

	SET(VISUALIZER_LIBS ${CAER_LIBS} ${SFML_LIBRARIES})
	SET(VISUALIZER_INCDIRS ${CAER_INCDIRS} ${SFML_INCLUDE_DIRS})
	SET(VISUALIZER_LIBDIRS ${CAER_LIBDIRS} ${SFML_LIBRARY_DIRS})

	PKG_CHECK_MODULES(GLEW REQUIRED glew>=1.10.0)

	SET(VISUALIZER_LIBS ${VISUALIZER_LIBS} ${GLEW_LIBRARIES})
	SET(VISUALIZER_INCDIRS ${VISUALIZER_INCDIRS} ${GLEW_INCLUDE_DIRS})
	SET(VISUALIZER_LIBDIRS ${VISUALIZER_LIBDIRS} ${GLEW_LIBRARY_DIRS})

	INCLUDE_DIRECTORIES(${VISUALIZER_INCDIRS})
	LINK_DIRECTORIES(${VISUALIZER_LIBDIRS})

	ADD_LIBRARY(visualizer SHARED visualizer.cpp visualizer_handlers.cpp visualizer_renderers.cpp)

	SET_TARGET_PROPERTIES(visualizer
		PROPERTIES
		PREFIX "caer_"
	)

	TARGET_LINK_LIBRARIES(visualizer ${VISUALIZER_LIBS})

	INSTALL(TARGETS visualizer DESTINATION ${CAER_MODULES_DIR})
ENDIF()
